#pragma once
#define _CRT_SECURE_NO_WARNINGS -1

#include<iostream>
using namespace std;
#include <stdio.h>
#include<stdlib.h>
static int i = 0;
struct TreeNode
{
    struct TreeNode* left;
    struct TreeNode* right;
    char val;
};

struct TreeNode* createTree(char* s)
{
    if (s[i] == '#')
    {
        (i)++;
        return NULL;
    }

    struct TreeNode* root = (struct TreeNode*)malloc(sizeof(struct TreeNode));
    root->val = s[(i)];
    (i)++;
    root->left = createTree(s);
    root->right = createTree(s);
    return root;
}

void BinaryTreeInOrder(struct TreeNode* root)
{
    if (root == NULL) return;
    BinaryTreeInOrder(root->left);
    printf("%c ", root->val);
    BinaryTreeInOrder(root->right);
};
//int main()
//{
//    char s[100];
//    scanf("%s", s);
//
//    struct TreeNode* root = createTree(s);
//    BinaryTreeInOrder(root);
//    return 0;
//}
#include"BinaryTree.h"
int main()
{
    int i = 0;
   const char* s = "ABD##E#H##CF##G##";
    BTNode* root =  BinaryTreeCreate(s,&i);
    BinaryTreeInOrder(root);
    printf("\n");
    BinaryTreeLevelOrder(root);
    int count = BinaryTreeLeafSize(root);
    printf("\n%d ", count);
    BinaryTreeDestory(root);
    return 0;
}